﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using BruteForce.Screens.PlayingScreen.Map;

namespace BruteForce.Utilities {
    public static class MapSerializer {
        
        public static void SerializeObject(string filename, List<MapRow> objectToSerialize) {
            Stream stream = File.Open(filename, FileMode.Create);
            BinaryFormatter bFormatter = new BinaryFormatter();
            bFormatter.Serialize(stream, objectToSerialize);
            stream.Close();
        }

        public static List<MapRow> DeSerializeObject(string filename) {
            List<MapRow> objectToSerialize;
            Stream stream = File.Open(filename, FileMode.Open);
            BinaryFormatter bFormatter = new BinaryFormatter();
            objectToSerialize = (List<MapRow>)bFormatter.Deserialize(stream);
            stream.Close();
            return objectToSerialize;
        }
    }
}
